package com.runner.suporte;

import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class VerDadosActivity extends Activity {
	@Override
	public void onCreate(Bundle icicle){
		super.onCreate(icicle);
		setContentView(R.layout.ver_dados);
		DadosBasicos db = new DadosBasicos(this);
		if (db.carregarDados()){
			obter(R.id.altura).setText(getString(R.string.altura,db.getAltura()));
			obter(R.id.peso).setText(getString(R.string.peso,db.getPeso()));
			obter(R.id.idade).setText(getString(R.string.idade,db.getIdade()));
			obter(R.id.bat10).setText(getString(R.string.bat10,db.getBat10()));
			float vIMC=(float)(db.getPeso()/Math.pow(db.getAltura(), 2));
			int vMHR = 220 - db.getIdade();
			int vRHM = db.getBat10() * 6;
			int VHRH - vMHR - vRHM;
			obter(R.id.sit_imc).setText(getString(R.string.imc,vIMC, desIMC(vIMC)));
			obter(R.id.sit_mTR).setText(getString(R.string.mintr,(int)((vHRH * 0.65) + vRHR)));
			obter(R.id.sit_MTR).setText(getString(R.string.maxtr,(int)((vHRH * 0.85) + vRHR)));
			obter(R.id.sit_MHR).setText(getString(R.string.mhr,vMHR));
			obter(R.id.sit_saude).setText(getString(R.string.fsaude,(int)(vMHR * 0.65), (int)(vMHR * 0.78)));
			obter(R.id.sit_aerobica).setText(getString(R.string.faerobica,(int)(vMHR * 0.65), (int)(vMHR * 0.85)));
			obter(R.id.sit_anaerobico).setText(getString(R.string.fanaerobica,(int)(vMHR * 0.78), (int)(vMHR * 0.90)));
			
		}
	}
	private String desIMC(float vIMC){
		if (vIMC < 18.5f)
			return " -" + getResources().getString(R.string.imc1);
		else if (vIMC < 24.9f)
			return " -" +getResources().getString(R.string.imc2);
		else if (vIMC < 29.9f)
			return " -" +getResources().getString(R.string.imc3);
		else if (vIMC < 34.9f)
			return " -" +getString(R.string.imc4, 1);
		else if (vIMC < 39.9f)
			return " -" +getString(R.string.imc4, 2);
		else
			return " -" +getString(R.string.imc4, 3);
		
	}
	private TextView obter(int id){
		return (TextView)findViewById(id);
	}
}
